package org.smile.homework01.kevin.Weapon;

public class Command {   //统筹武器命令
    private Attack attack;
    private Trace trace;
    private Detect detect;
     public Command(){
         this.attack = Attack.getInstance();
         this.trace = Trace.getInstance();
         this.detect = Detect.getInstance();
     }
    /**
     * 编写武器行为顺序
     */

    public void execute(){
        trace.begin();
        trace.end();
        attack.attack();
        attack.stopAttack();
        detect.begin();
        detect.detect();
        detect.end();
        int choice = (int) (Math.random() *10);
        if(detect.isDetect(choice)){
            System.out.println("检测目标仍存活");
            attack.attack();
        }else{
            System.out.println("检测目标未存活");
            trace.begin();
            trace.end();
        }
    }
}
